package me.firstapp.bbs.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import me.firstapp.bbs.base.BaseController;
import me.firstapp.common.json.SingleObject;
import me.firstapp.common.module.shop.JsonAddress;
import me.firstapp.common.utils.ResponseUtils;
import me.firstapp.spi.shop.AddressService;

@Controller
@RequestMapping("/address")
public class AddressController extends BaseController {

	@Autowired
	private AddressService addressService;

	@RequestMapping(value = "/addUpdateAddress.do", method = RequestMethod.POST)
	public void addUpdateAddress(String name, String mobile, String province, String city, String district,
			String detail, HttpServletRequest request, HttpServletResponse response) {
		Long memberId = getCurrentLoginMemberId(request, response);
		SingleObject<JsonAddress> result = addressService.addUpdateAddress(memberId, name, mobile, province, city,
				district, detail);
		ResponseUtils.renderJson(response, result);
	}
}
